package com.shoppingcart.mapper;

import com.shoppingcart.entity.Shoppingcart;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author guanfenga@yonyou.com
 * @since 2023-02-15
 */
@Mapper
public interface ShoppingcartMapper extends BaseMapper<Shoppingcart> {

    String colunm = "`shopCartID`, `customerId`, `productId`, `shopInfoId`, `quantity`, `createTime`, `stockUpDate`, `sku`, `discount`, `branchName`, `priceSnapshot`";

    /**
     * 根据用户id 进行查询
     * @param userId
     * @return
     */
    @Select(" SELECT * FROM mall_shoppingcart s where s.customerId = #{userId} order by s.createTime desc")
    List<Shoppingcart> queryShoppingcartToUserId(@Param("userId") String userId);

    @Select(" select * from mall_shoppingcart s order by s.createTime desc ")
    List<Shoppingcart> queryJava8ShoppingCart(Shoppingcart shoppingcart);
}
